package org.flyframework
{
	import flash.events.IEventDispatcher;
	
	import org.flyframework.command.FlyCommander;
	import org.flyframework.dialog.FlyDialog;
	import org.flyframework.dnd.FlyDND;
	import org.flyframework.rpc.FlyRPC;
	
	
	public class Fly
	{
		
		static public const DEBUG:uint = 0x0001;
		
		static public const WEAK_REFERENCE:uint = 0x0002;
		
		
		[Bindable]
		static public var debug:Boolean = false;
		
		
		[Bindable]
		public var dnd:FlyDND = new FlyDND();
		
		[Bindable]
		public var rpc:FlyRPC = new FlyRPC();
		
		[Bindable]
		public var cmd:FlyCommander = new FlyCommander();
		
		
		[Bindable]
		public var dialog:FlyDialog = new FlyDialog();
		
		
		//--------------------------------------------------------------------------
		// Init
		//--------------------------------------------------------------------------
		
		public function Fly()
		{
			
		}
		
		
		//--------------------------------------------------------------------------
		// Static
		//--------------------------------------------------------------------------
		
		static public function addListener( dispatcher:IEventDispatcher, type:String, listener:Function, flags:uint=0 ):void
		{
			// flags
			var onlyDebug:Boolean = flags & DEBUG;
			var weakReference:Boolean = flags & WEAK_REFERENCE;
			
			if( onlyDebug == false || Fly.debug )
			{
				dispatcher.addEventListener( type, listener, false, 0, weakReference );
			}
			
			// ???
//			var callback:FlyCallback = new FlyCallback( listener );
//			dispatcher.addEventListener( type, callback.callListener, false, 0, false );
		}
		
		
		//--------------------------------------------------------------------------
		// Public
		//--------------------------------------------------------------------------
		
		public function announce( eventName:String ):void
		{
			
		}
		
		public function execute( commandName:String ):void
		{
			
		}
		
		public function undo():void
		{
			
		}
		
	}
}